<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>订单管理 - 管理后台</title>
    <link rel="stylesheet" href="/static/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/css/public.css" media="all"/>
</head>
<body class="childrenBody">
<div class="layui-col-md12">
    <form class="layui-form " action="" method="get">
        <blockquote class="layui-elem-quote title">
            <span class="layui-breadcrumb">
                <a href="javascript:void(0);">订单管理</a>
                <a><cite>产品订单</cite></a>
            </span>
            <div class="layui-inline">
                <label class="layui-form-label">搜索</label>
                <div class="layui-input-inline">
                    <input name="transaction" value="" class="layui-input" placeholder="请输入订单号"/>
                </div>
                <div class="layui-input-inline">
                    <input name="name" value="" class="layui-input" placeholder="请输入产品名称"/>
                </div>
                <div class="layui-input-inline">
                    <select name="status" >
                        <option value="">支付状态</option>
                        <option value="1">已失效</option>
                        <option value="2">未支付</option>
                        <option value="3">支付定金</option>
                        <option value="4">支付全款</option>
                    </select>
                </div>
                <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="demo1">搜索</button>
            </div>
        </blockquote>
    </form>
    <table id="productOrderList" lay-filter="productOrderList" class="layui-table"></table>
    <script type="text/html" id="productOrderListTBar">
        <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">详情</a>
    </script>
    <script type="text/html" id="productOrderImage">
        <img src="/{{ d.product_image }}" style="height:30px;"/>
    </script>
</div>
<script src="/static/layui.js"></script>
<script>
    layui.use(['element', 'jquery', 'layer', 'table', 'form'], function () {
        var element=layui.element,
            layer = layui.layer,
            $ = layui.jquery,
            table = layui.table,
            form = layui.form;
        form.on('submit(demo1)', function(data){
            table.reload('productOrderListTable', {
                where: data.field,
                page: {
                    curr: 1
                }
            });
            return false;
        });
        layui.tableIns = table.render({
            elem: '#productOrderList',
            url: '{:url("productOrder/lists")}',
            cellMinWidth: 95,
            page: true,
            limit: 15,
            limits: [15, 20, 30, 50],
            id: "productOrderListTable",
            cols: [[
                {field: 'transaction', title: '订单号', width: 200, align: "center"},
                {field: 'product_name', title: '产品', align: "center"},
                {field: 'product_image', templet: '#productOrderImage', title: '产品图片', width: 200, align: "center"},
                {field: 'product_price', title: '产品价格（元）', width: 150, align: "center"},
                {field: 'price', title: '订单价格（元）', width: 150, align: "center"},
                {field: 'create_time', title: '下单时间', width: 200, align: "center"},
                {
                    field: 'pay_time', title: '支付时间', width: 200, align: "center", templet: function (d) {
                        switch(d.status){
                            case -3:
                                return '退款中';
                                break;
                            case -1:
                                return '已失效' + (d.refund_time ? '(已退款)' : '');
                                break;
                            case 0:
                                return '未支付';
                                break;
                            case 1:
                                return d.pay_time;
                                break;
                            case 2:
                                return d.all_pay_time;
                                break;

                        }
                    }
                },
                {title: '操作', templet: '#productOrderListTBar', fixed: 'right', width: 150, align: 'center'}
            ]]
        });
        $('.childrenBody').on('click', 'img', function () {
            var img = new Array;
            img.push({src: $(this).attr('src')});
            layer.photos({
                photos: {data: img},
                anim: 5
            });
        });
        table.on('tool(productOrderList)', function (obj) {
            var layEvent = obj.event,
                data = obj.data;
            if (layEvent === 'edit') {
                var index = layui.layer.open({
                    title: "编辑订单",
                    type: 2,
                    content: "{:url('productOrder/editOrder')}?id=" + data.order_id,
                    area: ['100%', '100%']
                });
            }
        });
    });
</script>
</body>
</html>